import request from '@/utils/axios/index'
import type { Dayjs } from 'dayjs';

/** 应收款管理信息 */
export interface ContractArchiveReceiveRecord {
          id: number; // id
          contractArchiveId: number; // 合同档案id
          instalmentCount: number; // 分期数
          status: string; // 收款状态
          receiveDate: string | Dayjs; // 收款日期
          receiveMoney: number; // 收款金额
          receiptCode: string; // 发票号
          alreadyReceiveMoney: number; // 已收金额
          serviceTerm: string; // 对应服务期
          remark: string; // 备注
          badDebtReason: string; // 坏账原因
          isValid: string; // 是否生效
          badDebtDate: string | Dayjs; // 坏账日期
          recorderName: string; // 经手人
          content: string; // 收款内容
          taxStatus: string; // 开票状态
  }

// 应收款管理 API
export const ContractArchiveReceiveRecordApi = {
  // 查询应收款管理分页
  getContractArchiveReceiveRecordPage: async (params: any) => {
    return await request.get({ url: `/biz/contract-archive-receive-record/page`, params })
  },

  // 查询应收款管理详情
  getContractArchiveReceiveRecord: async (id: number) => {
    return await request.get({ url: `/biz/contract-archive-receive-record/get?id=` + id })
  },

  // 新增应收款管理
  createContractArchiveReceiveRecord: async (data: ContractArchiveReceiveRecord) => {
    return await request.post({ url: `/biz/contract-archive-receive-record/create`, data })
  },

  // 修改应收款管理
  updateContractArchiveReceiveRecord: async (data: ContractArchiveReceiveRecord) => {
    return await request.put({ url: `/biz/contract-archive-receive-record/update`, data })
  },

  // 删除应收款管理
  deleteContractArchiveReceiveRecord: async (id: number) => {
    return await request.delete({ url: `/biz/contract-archive-receive-record/delete?id=` + id })
  },

  /** 批量删除应收款管理 */
  deleteContractArchiveReceiveRecordList: async (ids: number[]) => {
    return await request.delete({ url: `/biz/contract-archive-receive-record/delete-list?ids=${ids.join(',')}` })
  },

  // 导出应收款管理 Excel
  exportContractArchiveReceiveRecord: async (params) => {
    return await request.download({ url: `/biz/contract-archive-receive-record/export-excel`, params })
  },

  // 查询应收款管理前100条数据
  getContractArchiveReceiveRecordList: async (params: any) => {
    return await request.get({ url: `/biz/contract-archive-receive-record/getContractArchiveReceiveRecordList`, params })
  },
}
